package com.example.smartstart.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.smartstart.entity.StudentInfo;
import com.example.smartstart.entity.dto.StudentInfoDTO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.time.LocalDate;
import java.util.List;

@Mapper
@Repository
public interface StudentInfoMapper extends BaseMapper<StudentInfo> {
    @Select("select * from student_info")
    List<StudentInfo> listAllStudentInfo();

    @Select("select * from student_info where student_id = #{studentId}")
    StudentInfo getStudentInfoById(String studentId);

    @Select("SELECT * FROM student_info WHERE examiner_number = #{examinerNumber} AND RIGHT(id_number, 6) = #{idNumber}")
    StudentInfo findStudentInfo(@Param("examinerNumber")String examinerNumber,@Param("idNumber")String idNumber);

    @Update("update student_info set check_in_date = #{checkInDate}, status =#{status}, phone = #{phone},qq_number=#{qqNumber},email=#{email},graduate_school=#{grateSchool},origin=#{origin},address=#{address},photo=#{photo} where student_id = #{studentId}")
    void updateInfo(
            LocalDate checkInDate,
            String status,
            @Param("phone")String phone,
            @Param("qqNumber")String qqNumber,
            @Param("email")String email,
            @Param("grateSchool")String grateSchool,
            @Param("origin")String origin,
            @Param("address")String address,
            @Param("photo")String photo,
            @Param("studentId")String studentId
                    );

    List<StudentInfo> listByPage(StudentInfo studentInfo);

    Integer queryTotal(StudentInfo studentInfo);

    StudentInfoDTO getStudentInfoCount();

    List<StudentInfoDTO> getClassReportCount();

    List<StudentInfoDTO> getCollegeStudentSCount();

    List<StudentInfoDTO> getDepartmentStudentSCount();

}
